﻿#ifndef FUNCEVENT_H
#define FUNCEVENT_H
#include<QEvent>
#include"EventFilter.h"
#include"EventType.h"
//发送函数事件
class FuncEvent:public QEvent
{
public:
	friend class FuncEventFilter;
	FuncEvent(std::function<bool()> fun);
	FuncEvent(QObject* receiver,std::function<bool()> fun);
	//异步的方式发送事件必须创建在堆区，自动释放
	void postEvent(QObject* receiver,int priority = Qt::NormalEventPriority);
protected:
	std::function<bool()> m_fun;
};
//发送函数事件过滤器
class FuncEventFilter :public EventFilter
{
public:
	FuncEventFilter(QObject* parent = nullptr);
};
#endif 
